<?php


namespace app\zhongcan\controller;
use cmf\controller\AdminBaseController;
use think\facade\Db;

class BannerController extends AdminBaseController
{
    public function index()
    {
        return "<a href='add'>上传</a>";
    }
    public function add()
    {
        return $this->fetch('add');
    }
    public function addPost()
    {
        $image = $_POST['image'];
        $image = cmf_get_image_url($image);
        $res = Db::name('banner')->save([
            'image'=>$image,
            'url'=>'#'
        ]);
        if($res){
            return json(['code' => 1,'msg' => '保存成功','data' => null]);
        }else{
            return json(['code' => 0,'msg' => '保存失败','data' => null]);
        }
    }
}